<style>
    .wd300{
        width: 300px;
    }
</style>
<form action="{:sysuri()}" method="post" data-auto="true" class="layui-form layui-card" data-table-id="MenuTable">
    <div class="layui-card-body">
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('奖项名称')}</label>
            <div class="layui-input-block">
                <input name="title" value='{$vo.title|default=""}' 
                required vali-name="奖项名称" placeholder="请输入奖项名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('奖品值(元)')}</label>
            <div class="layui-input-block">
                <input name="integral" value='{$vo.integral|default=""}' 
                required vali-name="奖品值" placeholder="请输入奖品值" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('发放总数(元)')}</label>
            <div class="layui-input-block">
                <input name="count" value='{$vo.count|default=""}' 
                required vali-name="发放总数" placeholder="请输入发放总数" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('中奖概率(%)')}</label>
            <div class="layui-input-block">
                <input name="probability" value='{$vo.probability|default=""}' 
                required vali-name="中奖概率" placeholder="请输入中奖概率" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('奖品类型')}</label>
            <div class="layui-input-block">
                 <input type="radio" name="type" value="1" {if($vo["type"] == 1)} checked  {/if} title="积分">
                 <input type="radio" name="type" value="2" {if($vo["type"] == 2)} checked  {/if} title="实物">
                 <input type="radio" name="type" value="3" {if($vo["type"] == 3)} checked  {/if} title="红包" >
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">{:lang('是否显示')}</label>
            <div class="layui-input-block">
                 <input type="radio" name="status" value="1" {if($vo["status"] == 1)} checked  {/if} title="显示">
                 <input type="radio" name="status" value="0" {if($vo["status"] == 0)} checked  {/if} title="隐藏" >
            </div>
        </div>
    </div>

    <div class="hr-line-dashed"></div>
    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit'>{:lang('保存数据')}</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="{:lang('确定要取消编辑吗？')}" data-close>{:lang('取消编辑')}</button>
    </div>
</form>


<script>

      // 省份下拉菜单更新
      form.on('select(province)', function(data){
          $.ajax({
              url:"{:url('ajax_city')}",
              data:{id:data.value},
              type:"get",
              success:function(ret){
                  var cityOptions='';
                  var cities=JSON.parse(ret);
                  cities.forEach(function(city){
                     cityOptions += '<option value="' + city.area_code + '">' + city.name + '</option>';
                  });
                  $('#city').html(cityOptions);
                  form.render('select');
                  if(cities.length > 0){
                      $.ajax({
                          url:"{:url('ajax_city')}",
                          data:{id:cities[0].area_code},
                          type:"get",
                          success:function(ret){
                              var cityOptions='';
                              var cities=JSON.parse(ret);
                                 cities.forEach(function(city){
                                 cityOptions += '<option value="' + city.area_code + '">' + city.name + '</option>';
                              });
                              $('#district').html(cityOptions);
                              form.render('select');
                          }
                        })
                  }
                  
              }
          })
      });
 
      // 城市下拉菜单更新
      form.on('select(city)', function(data){
        
        $.ajax({
          url:"{:url('ajax_city')}",
          data:{id:data.value},
          type:"get",
          success:function(ret){
              var cityOptions='';
              var cities=JSON.parse(ret);
                 cities.forEach(function(city){
                 cityOptions += '<option value="' + city.area_code + '">' + city.name + '</option>';
              });
              $('#district').html(cityOptions);
              form.render('select');
          }
        })
      });
</script>














